import config from '../config'
import axios from 'axios'
import QS from 'qs'


const instance = axios.create({
  BaseUrl:config.baseURL,

  //将对象参数按照URL参数生成
  transformRequest:(data)=>{
  return QS.stringify(data);
  }
})

instance.interceptors.response.use((response)=>{
  return response.data;
},error => {
  return Promise.reject(error)
})

export default {
  get(url,params){
    return instance.get(url,{params});
  },
  post(url,params){
    return instance.post(url,params);
  }
}
